<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false" %>
<%@ page import="com.atozsoft.commonutil.Constants"%>
<%@page import="java.math.BigDecimal"%>
<%@page import="com.eos.data.datacontext.UserObject" %>
<%@page import="org.gocom.components.coframe.rights.dataset.CapUser"%>	

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- 
  - Author(s): houfy
  - Date: 2016-10-25 11:03:52
  - Description:
-->
<head>
	<%@include file="/common.jsp"%>
	<%@include file="/common/common.jsp"%>
    <%@include file="/coframe/tools/skins/common.jsp"%>
	<title>项目立项管理一览</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <%
        // 来源stepid
		String stepid = "";
		if(request.getParameter("stepid")!=null){
			stepid = (String)request.getParameter("stepid");
		}
		
	%>
</head>
<body>
	<div class="search-condition">
	<a href="#" class="searchclose"></a>
		<div class="list">
        	<div id="queryprojectForm">
	        	<table style="width:100%;" class="table">
	            	<tr>
	              		<!-- <td class="tit" style="width:120px">
	              			立项文件编号：
	              		</td>
	              		<td>
	                		<input id="projectfilecode" class="nui-textbox " onEnter='onKeyEnter' name="projectfilecode" style="width:100%"/>
	              		</td> -->
	              		<td class="tit" style="width:120px">
	              			项目名称：
	              		</td>
	              		<td>
	                		<!-- <input id="projectname" class="nui-textbox " onEnter='onKeyEnter' name="projectname" style="width:100%"/> -->
	                		<input name="criteria._expr[0].projectname" class="nui-textbox" style="width:100%" onenter="onKeyEnter"/>
	                		<input class="nui-hidden" name="criteria._expr[0]._op" value="like"/>
                        	<input class="nui-hidden" name="criteria._expr[0]._likeRule" value="all"/>
	              		</td>
		              	<td class="tit" style="width:120px">
                   			项目来源：
	              		</td>
	              		<td>
	                		<input id="projectfrom" class="nui-dictcombobox nui-form-input" name="criteria._expr[1].projectfrom"  onenter="onKeyEnter" allowInput="false" dictTypeId="MIS_PROJECTFROM"/>
	                		<input class="nui-hidden" name="criteria._expr[1]._op" value="="/>
        				</td>
        				<td class="tit" style="width:120px">
                   			资金来源：
	              		</td>
	              		<td>
		          			<input id="moneyfrom" class="nui-dictcombobox nui-form-input" style="width:100%;" onenter="onKeyEnter" name="criteria._expr[2].moneyfrom"  allowInput="false" dictTypeId="MIS_MONEYFROM"/>
		          			<input class="nui-hidden" name="criteria._expr[2]._op" value="="/>
		        		</td>
	              		<td width="20px"></td>
	            	</tr>
          		    <tr>
          		    	<td class="tit" style="width:120px">
	              			项目类型：
	              		</td>
	              		<td>
	                		<input id="projecttype" class="nui-dictcombobox nui-form-input" style="width:100%;" onenter="onKeyEnter" name="criteria._expr[3].projecttype"  allowInput="false" dictTypeId="MIS_PROJECTTYPE"/>
	                		<input class="nui-hidden" name="criteria._expr[3]._op" value="="/>
		        		</td>
		        		<td class="tit" style="width:120px">
	              			立项年度：
	              		</td>
	              		<td>
	                		<!-- <input id="planyear" class="nui-textbox " onEnter='onKeyEnter' name="planyear" style="width:100%"/> -->
	                		<input id="planyear" class="nui-textbox nui-form-input" onEnter='onKeyEnter' name="criteria._expr[4].planyear"  style="width:100%"/>
	                		<input class="nui-hidden" name="criteria._expr[4]._op" value="="/>
	              		</td>
	              		<td class="tit" style="width:120px">
                   			数据状态：
	              		</td>
	              		<td>
		          			<input id="status" class="nui-dictcombobox nui-form-input" style="width:100%;" onenter="onKeyEnter" name="criteria._expr[5].status"  allowInput="false" dictTypeId="PROCESS_STATUS_TYPE"/>
		          			<input class="nui-hidden" name="criteria._expr[5]._op" value="="/>
		        		</td>
		        		<td width="20px"></td>
	            	</tr>
	            	<tr>
	              		<td class="tit">
		              		申报时间：
		              	</td>
		              	<td nowrap="nowrap">
	                		<input id="startDate" class="nui-datepicker" onEnter='onKeyEnter' name="criteria._expr[6].declaringdate" style="width:48.5%;" onvalidation="onDateValidation" allowInput="false"/>
	                		<input class="nui-hidden" name="criteria._expr[6]._op" value=">="/>
							-
							<input id="endDate" class="nui-datepicker" onEnter='onKeyEnter' name="criteria._expr[7].declaringdate" style="width:48.5%;" onvalidation="onDateValidation" allowInput="false"/>
							<input class="nui-hidden" name="criteria._expr[7]._op" value="<="/>
		              	</td>
		              	<td class="tit" style="width:120px">
                   			申报单位：
	              		</td>
	              		<td>
	                		<input  id="declaringunitsid" class="nui-treeselect nui-form-input" name="criteria._expr[8].declaringunitsid" 
			       			url="com.shendong.mis.common.queryOrgOrganization.biz.ext" multiSelect="false"  valueFromSelect="false"
        					dataField="datas" textField="orgname" valueField="orgid" parentField="parentorgid"   allowInput="false"
       						showRadioButton="true" showFolderCheckBox="false" onbeforenodeselect="beforenodeselect" onenter="onKeyEnter"
    						/>
    						<input class="nui-hidden" name="criteria._expr[8]._op" value="="/>
        				</td>
	              		
	              		<td width="20px">
	              			<input class="nui-hidden" name="stepid" value="<%=stepid %>"/>
	              			<input class="nui-hidden" name="status" value="2"/>
	              		</td>
	            	</tr>
          		</table>
          		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="search-btn-area">
					  <tr>
					     <td>
					      	<a class="nui-button" iconCls="icon-search" onclick="search">查询</a>&nbsp;&nbsp;
					      	<a class="nui-button" iconCls="icon-reload" onclick="clear">清空</a>
					     </td>
					  </tr>
		        </table>
        	</div>
      	</div>
    </div>
	
    <div class="nui-fit">
  		<div id="projectDataGrid" class="nui-datagrid" style="width:100%;height:100%;"
  		 url="" dataField="datas"
          	sizeList=[10,20,50,100] multiSelect="false" pageSize="20" allowAlternating="true" >
        	<div property="columns">
        		<div field="projectid" visible="false">ID</div>
          		<div type="checkcolumn" headerAlign="center" align="center">
          		</div>
          		<div field="projectname" allowSort="true" headerAlign="center" renderer="urlRenderer" width="120px">
        			项目名称
          		</div>
          		<div field="projectfrom" allowSort="true" headerAlign="center" renderer="onRender">
        			项目来源
          		</div>
          		<div field="moneyfrom" allowSort="true" headerAlign="center" renderer="onRender" width="60px">
        			资金来源
          		</div>
          		<div field="projecttype" allowSort="true" headerAlign="center" renderer="onRender">
        			项目类型
          		</div>
          		<!-- <div field="declaringunitsid" visible="false">申报单位ID</div> -->
          		<div field="planyear" allowSort="true" headerAlign="center" >
        			立项年度
          		</div>
          		<div field="orgname" allowSort="true" headerAlign="center" >
        			申报单位
          		</div>
          		<div field="declaringdate" allowSort="true" headerAlign="center" >
        			申报日期
          		</div>
          		<div field="budgetamount" allowSort="true" headerAlign="center" >
        			经费预算（万元）
          		</div>
          		<div field="projectleader" visible="false">申报单位ID</div>
          		<div field="empname" allowSort="true" headerAlign="center" >
        			项目主管
          		</div>
          		<div field="status" allowSort="true" headerAlign="center" align="center" renderer="onRender">
            		数据状态
          		</div> 
          		<div field="creater" allowSort="true" headerAlign="center" visible="false" >
            		创建者
          		</div>
          		<div field="createdate" allowSort="true" headerAlign="center" align="center" dateFormat="yyyy-MM-dd" visible="false">
            		创建日期
          		</div> 
          		
          		<!-- 隐藏字段 -->
          		
          		<div field="processinstid" visible="false">流程实例ID</div>
          		<div field="departmentid" visible="false">业务主管部门ID</div>
          		<div field="departmentname" visible="false">业务主管部门名称</div>
          		<div field="bidamount" visible="false">项目经费</div>
          		<div field="bidwinner" visible="false">项目实施单位</div>
          		<div field="planyear" visible="false">立项年度</div>
          		<div field="technologyfield1" visible="false">所属技术领域</div>
          		<div field="resultdoneyear" visible="false">项目完成年度</div>
          		<div field="projectimplementationunit" visible="false">项目执行单位</div>
          		<div field="projecttype" visible="false">项目执行单位</div>
          		<div field="theme" visible="false">项目报奖里面的成果名称</div>
        	</div>
      	</div>
    </div>
    <div style="text-align:center;padding:10px;">
		<a class="nui-button" onclick="confirmSelection()" style="width:60px;margin-right:20px">确定</a>
		<a class="nui-button" onclick="close()" style="width:60px">取消</a>
	</div>
    <script>
    	//数据渲染处理
    	function onRender(e){
    		if(e.field=="projectfrom"){
    			return nui.getDictText("MIS_PROJECTFROM",e.value);
    		}else if(e.field=="moneyfrom"){
    			return nui.getDictText("MIS_MONEYFROM",e.value);
    		}else if(e.field=="projecttype"){
    			return nui.getDictText("MIS_PROJECTTYPE",e.value);
    		}else if (this.field=="status"){
        	    if(e.row.status == "2"){
        	    	dictText = "<a href='#' onclick='showWFgraph("+e.row.processinstid+");'>已审批</a>";
        	    }else if(e.row.status == "1"){
        	    	dictText = "<a href='#' onclick='showWFgraph("+e.row.processinstid+");'>审批中</a>";
        	    }else{
	        	    if(e.row.processinstid != "" && e.row.processinstid != null){
	        	    	dictText = "<a href='#' onclick='showWFgraph("+e.row.processinstid+");'>保存</a>";
	        	    }else{
	        	    	dictText = "保存";
	        	    }
        	    }
        		return dictText;
    		}
    	}
    	
    	
      	function showWFgraph(processInstId){
	    	var zoomvalue = 1;
	    	nui.open({
	            url: "<%=request.getContextPath()%>/wf/processOperate/process_Approve.jsp?processInstId=" + processInstId + "&zoomvalue=" + zoomvalue,
		        title: "查看审批进度",
				width: 700, 
		        height: 635,
		        onload: function() {
		        },
		        ondestroy: function (action) {
					
	             }
		    });
      	}
      	
      	// 清空查询条件
	   function clear(){
			var form = new nui.Form("#queryprojectForm");
			form.reset();
		}
    </script>
	<script type="text/javascript">
    	nui.parse();
    	
    	//跳转方式修改为弹出TAB
    	var postUrl="<%=request.getContextPath()%>/mis/common/postUrl.jsp?";

    	var grid = nui.get("projectDataGrid");
    	// 初始数据
    	//grid.load();
    	var stepid = "<%=stepid %>";
    	//alert(stepid);
    	if(stepid == "1"||stepid == "2"||stepid == "3"||stepid == "4"||stepid == "5"){
			grid.setUrl("com.shendong.mis.common.queryProjectEstablishment.biz.ext");
			grid.load({stepid:stepid,status:"2"});
		}else{
			//设置默认值
			grid.setUrl("com.shendong.mis.common.queryProjectEstablishment.biz.ext");
			grid.load({status:"2"});
		}
    	
    	var stepid = "<%=stepid %>";
		//search();
  		
  		  // 查询按钮
  		function search(){
  			var form = new nui.Form("#queryprojectForm");
		    var data = form.getData();//获取表单JS对象数据 
		    
		    grid.load(data);
  		}
  		
  		// 回车执行查询
  		function onKeyEnter(e) {
    		search();
  		}
  		//确定按钮
  		function onOk(e) {
 			save();
 		}
 		//取消按钮
		function close(){
	        CloseWindow("close");
	    }
		 // 确认选择
	    function confirmSelection() {
	    	var row = grid.getSelecteds();
       		if(row.length == 1){
                CloseWindow("ok");
            }else{
                nui.alert("请选择一条记录","提示");
            }
	    }
		
		 // 关闭事件
	    function CloseWindow(action){
	      if(window.CloseOwnerWindow) 
	        return window.CloseOwnerWindow(action);
	      else
	        return window.close();
	    }
	    
	    function GetData(){
	    	var row = grid.getSelected();
	    	//alert(nui.encode(row));
	    	return row;
	    
	    }
		
		 /*  // 页面数据取得
	     function SetData(data) {
	        data = nui.clone(data);
	        //var row = grid.getSelected();
	        var strUrl = "";
	        var json = "";
	        //stepid = 1时，查询已立项项目列表
	        //stepid = 2时，查询已招标项目列表
			if(data.stepid == "1"){
				strUrl = "com.shendong.mis.common.queryProjectEstablishment.biz.ext";
				json = nui.encode({status:"2"});
			}else if(data.stepid == "2"){
				//alert("1");
				strUrl = "com.shendong.mis.common.queryProjectTender.biz.ext";
				json = nui.encode({status:"2"});
			}
			grid.setUrl(strUrl);
			grid.load(json);
				
				
	     }  */
		 
  		
		//各种监听事件
        $(document).ready(
			function(){
			   //收起查询窗口
			   $(".search-condition .searchclose").click(function(){
			  		$(".search-condition .list").toggle();
					setTimeout("nui.layout()", 10 );
			   });
			}
		);
  		
  		// 结束日期不能小于开始日期检查
		function onDateValidation(e)
		{
			if (e.isValid) {
				var startDate = nui.get("startDate").getValue();
				var endDate = nui.get("endDate").getValue();
				if(startDate != null && startDate != "" && endDate != null && endDate != ""){
	                if (startDate > endDate) {
	                    e.errorText = "结束日期不能小于开始日期！";
	                    e.isValid = false;
	                }
	                else{
	                	nui.get("startDate").setIsValid(true);
	                	nui.get("endDate").setIsValid(true);
	                }
                }
            }
		}
		//写完treeSelect必须加这个函数，要不选不到
    	function beforenodeselect(e) {
            //禁止选中父节点
            if (e.isLeaf == false) e.cancel = true;
        } 
    </script>
</body>
</html>